package com.lq.memo.controller;

import com.lq.memo.entity.MyResponse;
import com.lq.memo.entity.User;
import com.lq.memo.exception.MyException;
import com.lq.memo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName UserController
 * @Description
 * @Author LQ
 * @Date 2021/11/14 15:44
 * @Version 1.0
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/getUser", method = {RequestMethod.POST, RequestMethod.GET})
    public MyResponse getUser(@RequestBody User user) {
        MyResponse response = new MyResponse();
        User queryRestUser = userService.getUser(user);
        response.success().data(queryRestUser);
        return response;
    }

    @RequestMapping(value = "/getAllUser", method = {RequestMethod.POST, RequestMethod.GET})
    public MyResponse getAllUser() {
        MyResponse response = new MyResponse();
        List<User> queryRestUserList = userService.getAllUser();
        response.success().data(queryRestUserList);
        return response;
    }

}
